gdk/Win32: Fix mouse pointer capture
authorChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 8 Oct 2020 07:55:29 +0000 (15:55 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 16 Oct 2020 02:03:50 +0000 (10:03 +0800)
Call SetCapture() explcitly for the (new) modal window so that we make the
modal window respond to mouse input, and also call SetCapture() to the parent
of the transient window that we are destroying so that mouse input capture is
returned to the parent window.

This attempts to fix the following:

*  Upon creating a new modal window, the new modal window does not receive
   pointer input unless one switches to another program and back

*  Upon closing a transient window, the parent window that activated the
   transient window does not receive pointer input unless one switches to
   another and back

gdk/win32/gdkevents-win32.c
gdk/win32/gdksurface-win32.c

index 24c300f9320fa486378a388e1f29aae3ff1dbbdc..8652f8c5f37c3538fc43546adddde73b0657b870 100644 (file)
@@ -2901,7 +2901,10 @@ gdk_event_translate (MSG *msg,
 
          if (impl->transient_owner &&
              GetForegroundWindow () == GDK_SURFACE_HWND (window))
-           SetForegroundWindow (GDK_SURFACE_HWND (impl->transient_owner));
+           {
+             SetForegroundWindow (GDK_SURFACE_HWND (impl->transient_owner));
+             SetCapture (GDK_SURFACE_HWND (impl->transient_owner));
+           }
        }
 
       if (!(windowpos->flags & SWP_NOCLIENTSIZE))
index 9ecbb6dbad96ad10be7eeef01850b61e84d4c50a..076e18aac1863217f5c8c8380ecb5be62a7b99b3 100644 (file)
@@ -4828,7 +4828,10 @@ gdk_win32_toplevel_set_property (GObject      *object,
       GDK_SURFACE (surface)->modal_hint = g_value_get_boolean (value);
 
       if (GDK_SURFACE (surface)->modal_hint)
-        _gdk_push_modal_window (surface);
+        {
+          SetCapture (GDK_SURFACE_HWND (surface));
+          _gdk_push_modal_window (surface);
+        }
 
       g_object_notify_by_pspec (G_OBJECT (surface), pspec);
       break;